package org.timemanager.view;

import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

/**
 * show a event's trend statistic chart
 * @author Dereky
 *
 */
public class EventTrendAnalyzeActivity extends Activity {
	public static Calendar curCalendar;
	/**
	 * record which event's trend static chart to be drawn.
	 */
	public static int eventId;
	public static String eventName;
	/**
	 * the view to draw the chart.
	 */
	private EventTrendAnalyzeView eventTrendCanvas;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		eventId=getIntent().getIntExtra("eventId", -1);
		eventName=getIntent().getStringExtra("eventName");
		/*
		 * make the the time complete the first day of month.
		 */
		curCalendar=Calendar.getInstance();
		curCalendar.set(Calendar.DAY_OF_MONTH, 1);
		curCalendar.set(Calendar.HOUR_OF_DAY, 0);
		curCalendar.set(Calendar.MINUTE,0);
		curCalendar.set(Calendar.SECOND, 0);
		curCalendar.set(Calendar.MILLISECOND, 0);
		
		setContentView(R.layout.event_trend_analyze);
		initAllConfiguration();
	}
	
	@Override
	protected void onStart() {
		super.onStart();
		eventTrendCanvas.showChart();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		eventTrendCanvas.close();
	}

	/**
	 * initialize all the global parameters.
	 */
	private void initAllConfiguration(){
		((TextView)findViewById(R.id.event_trend_title)).setText(eventName+
				getText(R.string.event_trend_title));
//		findViewById(R.id.event_trend_previous).setOnClickListener(new OnClickListener() {
//			
//			public void onClick(View v) {
//				
//			}
//		});
//		findViewById(R.id.event_trend_next).setOnClickListener(new OnClickListener() {
//			
//			public void onClick(View v) {
//				
//			}
//		});
		eventTrendCanvas=(EventTrendAnalyzeView) findViewById(R.id.event_trend_canvas);
	}
}
